<template>
	<el-config-provider :locale="locale" :size="size">
		<router-view />
	</el-config-provider>
</template>

<script setup lang="ts">
import { computed, nextTick, onMounted } from 'vue'
import { RouterView, useRouter } from 'vue-router'
import { useTitle } from '@vueuse/core'
import store from '@/store'
import { useI18n } from 'vue-i18n'
import { messages } from '@/i18n'
import { handleThemeStyle } from '@/utils/theme'
import { Storage } from '@/utils/storage'

const { t } = useI18n()
const locale = computed(() => messages[store.appStore.language].el)
const size = computed(() => store.appStore.componentSize)
const router = useRouter()
// 设置标题
useTitle(t('app.title'))

onMounted(async () => {
	// console.log(Storage.getItem('user_system'),Storage.getItem('token'),window.location.href.indexOf('/login'));

	if(!Storage.getItem('token') && window.location.href.indexOf('/login') == -1 && (window.location.href.indexOf('/pagemFinance/user/index') != -1 || window.location.href.indexOf('/pagelSuggestions/user') != -1)){
		router.replace({ path: '/login' })
	}
	// if(){
	// 	// 获取阿里云直传参数
	// 	const oss = await store.appStore.setOss()
	// }
	nextTick(() => {
		// 初始化主题样式
		handleThemeStyle(store.appStore.theme)
	})
})
</script>
